﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html lang="zh-CN">
  
  <head>
    
    <%@ include file="/WEB-INF/include/meta.jsp"%>
    <%@ include file="/WEB-INF/include/css.jsp"%>
    
  </head>
  <!-- end header -->
  <body>
    <div class="page-group">
      <div class="page page-current">
        
        <header class="bar bar-nav course-header">
          <c:if test="${not empty lastWeek}">
            <a href="${ctx.host}/course-schedules?start=${lastWeek}" class="button button-link button-nav pull-left"><span class="icon icon-left"></span>&nbsp;上周</a>
          </c:if>
          <h1 class="title">
            <fmt:formatDate value="${thisWeek[0]}" pattern="MM月dd日"/>&nbsp;～&nbsp;<fmt:formatDate value="${thisWeek[6]}" pattern="MM月dd日"/>
          </h1>
          <c:if test="${not empty nextWeek}">
            <a href="${ctx.host}/course-schedules?start=${nextWeek}" class="button button-link button-nav pull-right">下周&nbsp;<span class="icon icon-right"></span></a>
          </c:if>
        </header>

        <div class="content bg-white" style="margin-bottom:2.2rem;">
          <div class="color-annotation">
            <p class="no-margin text-center">上课：
              <span><a class="group"></a>团课</span>
              <span><a class="individual"></a>1v1</span>
              <span><a class="year"></a>年卡</span>
            </p>
            <p class="no-margin text-center">休息：<span><a class="rest"></a>休息</span>
              <span><a class="experience"></a>体验课</span>
              <span><a class="business"></a>公出</span>
              <span><a class="duty"></a>值班</span>
              <span><a class="annual-leave"></a>值班</span>
              <span><a class="conference"></a>会议</span>
              <span><a class="training"></a>培训</span>
            </p>
            
          </div>
          <ul class="week ${thisWeek[6].before(today) ? 'course-disable' : ''}">
            <c:forEach var="item" items="${thisWeek}">
              <li class="week-item week-rest-item">
                <div class="item-title">
                  <p>
                    <fmt:formatDate value="${item}" pattern="E"/><br>
                    <small><fmt:formatDate value="${item}" pattern="MM月dd日"/></small>
                    <fmt:formatDate value="${item}" pattern="yyyy-MM-dd" var="date"/>
                  </p>
                </div>
                <div class="item-content">
                  <div class="row">
                    <c:forEach var="hour" begin="${persist.coachRelation[coachId].site.businessStart[0]}" end="${persist.coachRelation[coachId].site.businessEnd[1] == '30' ? persist.coachRelation[coachId].site.businessEnd[0] : persist.coachRelation[coachId].site.businessEnd[0]-1}">
                      <c:set var="dayhour" value="${date}|${hour<10 ? '0' : ''}${hour}:00"></c:set>
                      <c:set var="halfhour" value="${date}|${hour<10 ? '0' : ''}${hour}:30"></c:set>
                      <c:set var="beforehalfhour" value="${date}|${hour<10 ? '0' : ''}${hour-1}:30"></c:set>
                      <div class="col-25">
                        <c:set var="dayhourHref" value="${ctx.host}/course-schedules?day=${date}&hour=${hour<10 ? '0' : ''}${hour}:00"/>
                        <c:set var="halfhourHref" value="${ctx.host}/course-schedules?day=${date}&hour=${hour<10 ? '0' : ''}${hour}:30"/>
                        <c:set var="beforehalfhourHref" value="${ctx.host}/course-schedules?day=${date}&hour=${hour<10 ? '0' : ''}${hour-1}:30"/>
                        <a href="${not empty schedules[dayhour] ? dayhourHref : not empty schedules[beforehalfhour] ? beforehalfhourHref : 'javascript:void(0);'}" 
                           class="${not empty schedules[dayhour] ? schedules[dayhour][0].course.experience ? 'experience' : schedules[dayhour][0].courseType.alias : not empty schedules[beforehalfhour] ? schedules[beforehalfhour][0].course.experience ? 'experience' : schedules[beforehalfhour][0].courseType.alias : not empty restSchedules[dayhour] ? empty persist.dutyCalendar(restSchedules[dayhour]) ? 'duty' : persist.dutyCalendar(restSchedules[dayhour]).coachRestType.alias : ''}" 
                           style="text-align:right;">${hour<10 ? '0' : ''}${hour}:
                        </a><a href="${not empty schedules[dayhour] ? dayhourHref : not empty schedules[halfhour] ? halfhourHref : 'javascript:void(0);'}" 
                               class="${not empty schedules[halfhour] ? schedules[halfhour][0].course.experience ? 'experience' : schedules[halfhour][0].courseType.alias : not empty schedules[dayhour] ? schedules[dayhour][0].course.experience ? 'experience' : schedules[dayhour][0].courseType.alias : not empty restSchedules[halfhour] ? empty persist.dutyCalendar(restSchedules[halfhour]) ? 'duty' : persist.dutyCalendar(restSchedules[halfhour]).coachRestType.alias : ''}" 
                               style="text-align:left;">00
                            </a>
                      </div>
                    </c:forEach>
                    
                    <c:if test="${item>=currentTime}">
                      <div class="col-25"><a href="${ctx.host}/rest-calendars/arrange?day=${date}" class="add-rest-btn"><i class="icon icon-add"></i></a></div>
                    </c:if>
                  </div>
                </div>
              </li>
            </c:forEach>
          </ul>
        </div>
        
        <nav class="bar bar-tab">
          <a class="tab-item external clear-link" href="javascript:void(0);" data-link="${ctx.host}/rest-calendars/clear" data-start="<fmt:formatDate value="${thisWeek[0]}" pattern="yyyy-MM-dd"/>" style="color: #333; border-right: 1px solid #ccc;">
            <span class="tab-label">清空</span>
          </a>
          <a class="tab-item external copy-link" href="javascript:void(0);" data-link="${ctx.host}/rest-calendars/copy" data-start="<fmt:formatDate value="${thisWeek[0]}" pattern="yyyy-MM-dd"/>" style="color: #333; background-color: #FEDC32;">
            <span class="tab-label">复制上一周</span>
          </a>
        </nav>
        
        
      </div>
    </div>
    
    <%@ include file="/WEB-INF/include/script.jsp"%>
    <d:resource type="script" root="${ctx.resource}/build" src="js/page/rest/arrange.js">
    <script type="text/javascript">
      require(['page/rest/arrange'], function(page) {
        page.init()
      })
    </script>
    </d:resource>
    
  </body>
</html>